<?php

namespace magein\think\pay\middleware;

use Closure;
use think\facade\Log;

class NotifyMiddleware
{
    /**
     * @param $request
     * @param Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $pay_no = request()->route('pay_no');

        $get = json_encode(request()->get());
        $post = json_encode(request()->post());
        $input = file_get_contents('php://input');

        $message = <<<EOF
=============notify=============
  pay_no:$pay_no
  get:$get
  post:$post
  input:$input
EOF;

        Log::channel('pay')->debug($message);

        return $next($request);
    }
}